<script>
  var my_string="It was the bast of times.";
  var result=my_string.split(" ");
  for(var i=0; i<result.length; i++)
  {
    var temp=result[i];
    var upperletter=temp.substring(0,1).toUpperCase();
    result[i]=upperletter+temp.substring(1);
  }
  document.write(result.join(" "));
</script>
